package com.dazzle.core.web.servlet;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@SuppressWarnings("serial")
public class ImageShowServlet extends HttpServlet {

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String imgPath = req.getParameter("imgPath");
		String file = "D:/workspace40/dazzle/src/main/webapp/" + imgPath;
		FileInputStream in = new FileInputStream(new File(file));
		OutputStream o = resp.getOutputStream();
		int l = 0;
		byte[] buffer = new byte[4096];
		while ((l = in.read(buffer)) != -1) {
			o.write(buffer, 0, l);
		}
		o.flush();
		in.close();
		o.close();

	}
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}

}
